package com.trafficsys.modules.loginAndRegister.util;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

/**
 * @Author Zhao Bin
 * @Date 2021/9/29 9:03
 * @Version 1.0
 */
@Component
public class MD5Util {
    private static final String SALT = "&%5123***&&%%$$#@";
    // MD5加密  加盐
    public  String getMD5(String password) {
        if (StringUtils.isBlank(password)) {
            return null;
        }
        String base = password + "/" + SALT;
        return DigestUtils.md5DigestAsHex(base.getBytes());
    }

    public static void main(String[] args) {
        MD5Util md5Util=new MD5Util();
        System.out.println(md5Util.getMD5("123456"));
    }
}